//导航栏颜色
var colors = document.querySelector(".nav-top").querySelectorAll("a");
for(var i = 0;i <colors.length;i++){
	colors[i].onmouseover = function (){
		this.style.color = "#FFFFFF";
	}
	colors[i].onmouseout = function (){
		this.style.color = "#B0B0B0";
	}
}
//购物车
function shopping(){
	document.querySelector("#nav-top-right-li a").style.color="#ff6600";
	$("#nav-top-right-li").css("background-color","#FFFFFF");
	$("#nav-top-right-sp").show();
	$("#nav-top-right-li span").css("color","#ff6600");
}
function outshopping(){
	document.querySelector("#nav-top-right-li a").style.color="#B0B0B0";
	$("#nav-top-right-li").css("background-color","#333");
	$("#nav-top-right-sp").show();
	$("#nav-top-right-sp").hide();
	$("#nav-top-right-li span").css("color","#B0B0B0");
}
// 导航栏底部推荐鼠标颜色改变
var buttomcolor = document.querySelector("#nav-buttom-ul ul").querySelectorAll("a");
for(var j = 0;j < buttomcolor.length;j++){
	buttomcolor[j].onmouseover = function (){
		this.style.color = "#ff6600";
	}
	buttomcolor[j].onmouseout = function (){
		this.style.color = "#333";
	}
 }
 var button = document.querySelector("#nav-buttom-input button");
 button.onmouseover = function (){
	 this.style.color = "#fff";
	 this.style.backgroundColor = "#ff6600";
 }
 button.onmouseout = function (){
	 this.style.color = "#333";
	 this.style.backgroundColor = "";
 }
 // 导航栏左边分类
 var contentlefts = $("#content-left ul li");
 for(var i = 0 ;i < contentlefts.length;i++){
	 contentlefts[i].onmouseover = function (){
		 this.style.backgroundColor = "#ff6600";
	 }
	 contentlefts[i].onmouseout = function (){
		 this.style.backgroundColor = "";
	 }
 }
 //轮播图
var time = 1;
var timer = setInterval(function(){
	++time;
	if(time == 4){
		time = 1;
	}
	$("#content-right img").fadeOut(1000,function(){
		$("#content-right img").attr("src","img/"+time+".webp");
		$("#content-right img").fadeIn(1000);
	});
},5000);
//按钮
$("#left").mouseenter(function (){
	$("#left").css("background-color","rgba(144, 140, 140, 0.6)");
	clearTimeout(timer);
}); 
$("#left").click(function (){
	if(time >1){
		$("#content-right img").fadeOut(1000,function(){
			--time;
			$("#content-right img").attr("src","img/"+time+".webp");
			$("#content-right img").fadeIn(1000);
		});
	}
});
$("#left").mouseleave(function(){
	$("#left").css("background-color","");
	timer = setInterval(function(){
		++time;
		if(time == 4){
			time = 1;
		}
		$("#content-right img").fadeOut(1000,function(){
			$("#content-right img").attr("src","img/"+time+".webp");
			$("#content-right img").fadeIn(1000);
		});
	},5000);
});
$("#right").mouseenter(function (){
	$("#right").css("background-color","rgba(144, 140, 140, 0.6)");
	clearTimeout(timer);
}); 
$("#right").click(function (){
	if(time < 3){
		$("#content-right img").fadeOut(1000,function(){
			++time;
			$("#content-right img").attr("src","img/"+time+".webp");
			$("#content-right img").fadeIn(1000);
		});
	}
});
$("#right").mouseleave(function(){
	$("#right").css("background-color","");
	timer = setInterval(function(){
		++time;
		if(time == 4){
			time = 1;
		}
		$("#content-right img").fadeOut(1000,function(){
			$("#content-right img").attr("src","img/"+time+".webp");
			$("#content-right img").fadeIn(1000);
		});
	},5000);
});
//图片获取焦点消除定时器
$("#content-right img").mouseenter(function(){
	clearTimeout(timer);
});
//重启定时器
$("#content-right img").mouseleave(function(){
	timer = setInterval(function(){
		++time;
		if(time == 4){
			time = 1;
		}
		$("#content-right img").fadeOut(1000,function(){
			$("#content-right img").attr("src","img/"+time+".webp");
			$("#content-right img").fadeIn(1000);
		});
	},5000);
});
//推荐图片动画
var imgs = $("#content-center").find("img");
for(var i = 0;i<imgs.length;i++){
	imgs[i].onmouseover = function (){
		$(this).animate({top:"-4px"});
	}
	imgs[i].onmouseout = function (){
		$(this).animate({top:"0px"});
	}
}
//商品动画
var sp = $("#content-detailed").find("ul>li");
for(var i = 0;i<sp.length;i++){
	sp[i].onmouseover = function (){
		$(this).animate({top:"-4px"});
	}
	sp[i].onmouseout = function (){
		$(this).animate({top:"0px"});
	}
}
//底部字体
var hpas = $("#buttom-help").find("ul>li>a");
for(var i = 0;i<hpas.length;i++){
	hpas[i].onmouseover = function (){
		$(this).css("color","#ff6600");
	}
	hpas[i].onmouseout = function (){
		$(this).css("color","");
	}
}
//底部a标签效果
$("#fotter li>a").mouseenter(function(){
	$(this).css("color","#ff6600");
});
$("#fotter li>a").mouseleave(function(){
	$(this).css("color","#616161");
});
//底部人工客服效果
$("#tt").mouseenter(function (){
	$(this).css("background-color","#ff6600");
	$("#tt a").css("color","#fff");
	$("#tt i").css("color","#fff");
});
$("#tt").mouseleave(function (){
	$(this).css("background-color","");
	$("#tt a").css("color","#ff6600");
	$("#tt i").css("color","#ff6600");
}); 
//侧边栏
var srs = $("#sidebar").find("li");
for(var i =0;i<srs.length;i++){
	srs[i].onmouseover = function(){
	$(this).children("p").css("color","#ff6600");
	$(this).children("i").css("color","#ff6600");
    };
	srs[i].onmouseout = function(){
	$(this).children("p").css("color","");
	$(this).children("i").css("color","");
	};
}
// 返回顶部
$(function() {
	var d_top = $("#rn");
	document.onscroll = function() {
		var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
		if (scrTop > 900) {
			d_top.show();
		} else {
			d_top.hide();
		}
	}
	$("#rn").click(function() {
		scrollTo(0, 0);
		this.blur();
		return false;
	});
});
$("#sidebar-li").click(function(){
	location.href = "spcar.html";
});
